/* -----------------------------------------------------------------------------
 * PROJECT    : net.lwf
 * FILE       : ShapeData.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Dec 23, 2008       Raghu Sarraff			       Created
 */
package lwf.handler.entities.shape;

import java.util.StringTokenizer;

import lwf.factory.PropertyReader;
import net.lwf.common.constant.ICommonConstant;

/**
 * Type the class description here
 *  
 */
public class ShapeData {
	
	private int shapecode;
	private int colorcode;
	private String name;
	private String description;
	private String question;

	
	
	/**
	 * @param shapecode
	 * @param colorcode
	 */
	public ShapeData(int shapecode, int colorcode) {
		this.shapecode = shapecode;
		this.colorcode = colorcode;
		this.processdata(shapecode);
	}
	/**
	 * @return Returns the description.
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * @return Returns the name.
	 * Populated from the property file
	 */
	public String getName() {
		return name;
	}
	/**
	 * @return Returns the question.
	 */
	public String getQuestion() {
		return question;
	}
	
	/**
	 * @return Returns the colorcode.
	 */
	public int getColorcode() {
		return colorcode;
	}
	
	private void processdata(int shapecode) {
		String data = (String) PropertyReader.getInstance().getShapeInfo().get(String.valueOf(shapecode));
		if(data != null && data.trim().length() != 0) {
			StringTokenizer stk = new StringTokenizer(data, ",");
			this.name = stk.nextToken();
			this.description = stk.nextToken();
			this.question = stk.nextToken();
		}
	}
	
	public String getColorHtml() {
		String color = "";
		switch(this.colorcode) {
		    case ICommonConstant.RED:
		    	color = "<font color=\"red\">red</font>";
		    	break;
		    case ICommonConstant.ORANGE:
		    	color = "<font color=\"orange\">orange</font>";
		    	break;
		    case ICommonConstant.BLUE:
		    	color = "<font color=\"blue\">blue</font>";
		    	break;
		    case ICommonConstant.GREEEN:
		    	color = "<font color=\"green\">green</font>";
		    	break;
		    case ICommonConstant.YELLOW:
		    	color = "<font color=\"yellow\">yellow</font>";
		    	break;
		    case ICommonConstant.PURPLE:
		    	color = "<font color=\"purple\">purple</font>";
		    	break;
		    case ICommonConstant.GREY:
		    	color = "<font color=\"gray\">gray</font>";
		    	break;
		    case ICommonConstant.PINK:
		    	color = "<font color=\"pink\">pink</font>";
		    	break;
		    case ICommonConstant.BROWN:
		    	color = "<font color=\"brown\">brown</font>";
		    	break;
		    case ICommonConstant.BLACK:
		    	color = "<font color=\"black\">black</font>";
		    	break;
		    default:
		    	color = "<font>white</font>";
		    	break;
		}
		
		return color;
	}
	
}

